//
//  DetailHeader.m
//  体育
//
//  Created by liujianlong on 2022/10/24.
//

#import "DetailHeader.h"
@interface DetailHeader()
@property (strong, nonatomic) IBOutlet UIButton *historyBtn;
@property (strong, nonatomic) IBOutlet UIButton *detailBtn;
@property (strong, nonatomic) IBOutlet UIButton *rankBtn;
@property (strong, nonatomic) IBOutlet UIButton *fiveBtn;
@property (strong, nonatomic) IBOutlet UIButton *tenBtn;
@property (strong, nonatomic) IBOutlet UIView *bgView2;
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *imgBottom;
@property (strong, nonatomic) IBOutlet UIButton *tipsBtn;
@property (strong, nonatomic) IBOutlet UIView *bgFive;

@end
@implementation DetailHeader

- (void)awakeFromNib{
    [super awakeFromNib];
    [self sendSubviewToBack:self.bgimg];
}
- (IBAction)actionForBtn:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (self.block) {
        self.block(sender.tag);
    }
}
- (void)setup:(UIButton *)btn1 btn2:(UIButton*)btn2{
    [self setup:btn1 condition:[btn1 isEqual:btn2]];
}
- (void)setup:(UIButton *)btn1 condition:(BOOL)equal{
    btn1.selected  = equal;
    btn1.bgHexColor = btn1.selected ? @"#FFFFFF":@"#2756CA";
}
- (void)setType:(DetailType)type{
    _type = type;
    [self setup:self.historyBtn condition:self.historyBtn.tag == type];
    [self setup:self.detailBtn condition:self.detailBtn.tag == type];
    [self setup:self.rankBtn condition:self.rankBtn.tag == type];
    self.imgBottom.constant = type == DetailTypeInfo ? 119 - 64 : 119;
    self.bgView2.hidden = type == DetailTypeInfo;
    self.fiveBtn.hidden = type != DetailTypeHistory;
    self.tenBtn.hidden = self.fiveBtn.hidden;
    if (type == DetailTypeHistory) {
        self.imgBottom.constant = 119;
        self.bgView2.hidden = NO;
        self.bgFive.hidden = NO;
        [self.tipsBtn setTitle:LS(@"全部赛事") forState:UIControlStateNormal];
    }else if (type == DetailTypeInfo){
        self.imgBottom.constant = 119 - 64;
        self.bgView2.hidden = YES;
        self.bgFive.hidden = YES;
        [self.tipsBtn setTitle:LS(@"") forState:UIControlStateNormal];
    }else if (type == DetailTypeRank){
        self.imgBottom.constant = 119;
        self.bgView2.hidden = NO;
        self.bgFive.hidden = YES;
        [self.tipsBtn setTitle:LS(@"联赛积分排名") forState:UIControlStateNormal];
    }
}
- (void)setIsfive:(BOOL)isfive{
    _isfive = isfive;
    [self setup:self.fiveBtn condition:isfive];
    [self setup:self.tenBtn condition:!isfive];
}
@end
